home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Complete Linux
/
Complete Linux.iso
/
xwindows
/
demos
/
xfract_1.z
/
xfract_1
/
xfractint-1.06
/
realdos.c
< prev
next >
Wrap
C/C++ Source or Header
|
1992-09-28
|
50KB
|
1,719 lines
/*
Miscellaneous C routines used only in DOS Fractint.
*/
#include <string.h>
#include <stdio.h>
#ifndef XFRACT
#include <dos.h>
#include <io.h>
#include <process.h>
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <math.h>
#include <stdlib.h>
#include <ctype.h>
#include "fractint.h"
#include "fractype.h"
#include "helpdefs.h"
#include "prototyp.h"
/* routines in this module */
static int menu_checkkey(int curkey,int choice);
int release=1727; /* this has 2 implied decimals; increment it every synch */
int xrelease=106;
/* fullscreen_choice options */
#define CHOICERETURNKEY 1
#define CHOICEMENU 2
#define CHOICEHELP 4
extern int xdots, ydots, sxdots, sydots, sxoffs, syoffs;
extern int colors;
extern int dotmode;
extern int oktoprint;
extern int textrow, textcol, textrbase, textcbase;
extern int debugflag;
extern int fractype;
extern int calc_status;
extern double param[];
extern int tabmode;
extern int color_dark,color_medium,color_bright;
extern int lookatmouse;
extern int gotrealdac;
extern int reallyega;
extern int extraseg;
extern int active_system;
extern int first_init;
/* int stopmsg(flags,message) displays message and waits for a key:
message should be a max of 9 lines with \n's separating them;
no leading or trailing \n's in message;
no line longer than 76 chars for best appearance;
flag options:
&1 if already in text display mode, stackscreen is not called
and message is displayed at (12,0) instead of (4,0)
&2 if continue/cancel indication is to be returned;
when not set, "Any key to continue..." is displayed
when set, "Escape to cancel, any other key to continue..."
-1 is returned for cancel, 0 for continue
&4 set to suppress buzzer
&8 for Fractint for Windows & parser - use a fixed pitch font
&16 for info only message (green box instead of red in DOS vsn)
*/
int stopmsg (int flags, CHAR far *msg)
{
int ret,toprow,color,savelookatmouse;
if (active_system == 0 /* DOS */
&& first_init) { /* & cmdfiles hasn't finished 1st try */
setvideotext();
buzzer(2);
putstring(0,0,15,"*** Error during startup:");
putstring(2,0,15,msg);
movecursor(8,0);
#ifdef XFRACT
sleep(1);
UnixDone();
#endif
exit(1);
}
ret = 0;
savelookatmouse = lookatmouse;
lookatmouse = -13;
if ((flags & 1))
blankrows(toprow=12,10,7);
else {
stackscreen();
toprow = 4;
movecursor(4,0);
}
textcbase = 2; /* left margin is 2 */
putstring(toprow,0,7,msg);
if (flags & 2)
putstring(textrow+2,0,7,"Escape to cancel, any other key to continue...");
else
putstring(textrow+2,0,7,"Any key to continue...");
textcbase = 0; /* back to full line */
color = (flags & 16) ? C_STOP_INFO : C_STOP_ERR;
setattr(toprow,0,color,(textrow+1-toprow)*80);
movecursor(25,80); /* cursor off */
if ((flags & 4) == 0)
buzzer((flags & 16) ? 0 : 2);
while (keypressed()) /* flush any keyahead */
getakey();
if (getakeynohelp() == ESC)
ret = -1;
if ((flags & 1))
blankrows(toprow,10,7);
else
unstackscreen();
lookatmouse = savelookatmouse;
return ret;
}
static char far *temptextsave = NULL;
static int textxdots,textydots;
/* texttempmsg(msg) displays a text message of up to 40 characters, waits
for a key press, restores the prior display, and returns (without
eating the key).
It works in almost any video mode - does nothing in some very odd cases
(HCGA hi-res with old bios), or when there isn't 10k of temp mem free. */
int texttempmsg(char *msgparm)
{
if (showtempmsg(msgparm))
return(-1);
#ifndef XFRACT
while (!keypressed()) {} /* wait for a keystroke but don't eat it */
#else
waitkeypressed(0); /* wait for a keystroke but don't eat it */
#endif
cleartempmsg();
return(0);
}
int showtempmsg(char *msgparm)
{
extern int color_dark,color_medium;
CHAR msg[41];
BYTE buffer[640];
char far *fartmp;
BYTE far *fontptr;
BYTE *bufptr;
int i,j,k,xrepeat,yrepeat,fontchar,charnum;
int save_sxoffs,save_syoffs;
strncpy(msg,msgparm,40);
msg[40] = 0; /* ensure max message len of 40 chars */
if (dotmode == 11) { /* disk video, screen in text mode, easy */
dvid_status(0,msg);
return(0);
}
if ((fontptr = findfont(0)) == NULL) { /* old bios, no font table? */
if (oktoprint == 0 /* can't printf */
|| sxdots > 640 || sydots > 200) /* not willing to trust char cell size */
return(-1); /* sorry, message not displayed */
textydots = 8;
textxdots = sxdots;
}
else {
xrepeat = (sxdots >= 640) ? 2 : 1;
yrepeat = (sydots >= 300) ? 2 : 1;
textxdots = strlen(msg) * xrepeat * 8;
textydots = yrepeat * 8;
}
/* worst case needs 10k */
if ((temptextsave = farmemalloc((long)textxdots * textydots)) == NULL)
return(-1); /* sorry, message not displayed */
save_sxoffs = sxoffs;
save_syoffs = syoffs;
sxoffs = syoffs = 0;
fartmp = temptextsave;
for (i = 0; i < textydots; ++i) {
get_line(i,0,textxdots-1,buffer);
for (j = 0; j < textxdots; ++j) /* copy it out to far memory */
*(fartmp++) = buffer[j];
}
if (fontptr == NULL) { /* bios must do it for us */
home();
printf(msg);
}
else { /* generate the characters */
find_special_colors(); /* get color_dark & color_medium set */
for (i = 0; i < 8; ++i) {
memset(buffer,color_dark,640);
bufptr = buffer;
charnum = -1;
while (msg[++charnum] != 0) {
fontchar = *(fontptr + msg[charnum]*8 + i);
for (j = 0; j < 8; ++j) {
for (k = 0; k < xrepeat; ++k) {
if ((fontchar & 0x80) != 0)
*bufptr = color_medium;
++bufptr;
}
fontchar <<= 1;
}
}
for (j = 0; j < yrepeat; ++j)
put_line(i*yrepeat+j,0,textxdots-1,buffer);
}
}
sxoffs = save_sxoffs;
syoffs = save_syoffs;
return(0);
}
void cleartempmsg()
{
BYTE buffer[640];
char far *fartmp;
int i,j;
int save_sxoffs,save_syoffs;
if (dotmode == 11) /* disk video, easy */
dvid_status(0,"");
else if (temptextsave != NULL) {
save_sxoffs = sxoffs;
save_syoffs = syoffs;
sxoffs = syoffs = 0;
fartmp = temptextsave;
for (i = 0; i < textydots; ++i) {
for (j = 0; j < textxdots; ++j) /* copy back from far memory */
buffer[j] = *(fartmp++);
put_line(i,0,textxdots-1,buffer);
}
farmemfree(temptextsave);
temptextsave = NULL;
sxoffs = save_sxoffs;
syoffs = save_syoffs;
}
}
void blankrows(int row,int rows,int attr)
{
char buf[81];
memset(buf,' ',80);
buf[80] = 0;
while (--rows >= 0)
putstring(row++,0,attr,buf);
}
void helptitle()
{
char msg[80],buf[10];
setclear(); /* clear the screen */
#ifdef XFRACT
sprintf(msg,"XFRACTINT Version %d.%02d (FRACTINT Version %d.%02d)",
xrelease/100,xrelease%100, release/100,release%100);
putstringcenter(0,0,80,C_TITLE,msg);
#else
#ifdef WAITE
sprintf(msg,"Special FRACTINT Version %d.%01d",release/100,(release%100)/10);
#else
sprintf(msg,"FRACTINT Version %d.%01d",release/100,(release%100)/10);
#endif
if (release%10) {
sprintf(buf,"%01d",release%10);
strcat(msg,buf);
}
#ifdef WAITE /* realdos.c */
strcat(msg," for the Waite Group's Fractal Creations");
#endif /* WAITE - realdos.c */
putstringcenter(0,0,80,C_TITLE,msg);
#ifdef WAITE
return;
#endif
#endif
/* uncomment next for production executable: */
return;
/*NOTREACHED*/
if (debugflag == 3002) return;
putstring(0,2,C_TITLE_DEV,"Development Version");
/* replace above by next after creating production release, for release source */
/* putstring(0,3,C_TITLE_DEV, "Customized Version"); */
putstring(0,53,C_TITLE_DEV,"Not for Public Release");
}
int putstringcenter(int row, int col, int width, int attr, char far *msg)
{
char buf[81];
int i,j,k;
i = 0;
#ifdef XFRACT
if (width==80) width=79; /* Some systems choke in column 80 */
#endif
while (msg[i]) ++i; /* st